<?php
header('Content-Type:text/html;charset=UTF-8');

session_start();

if(isset($_SESSION['user'])){

}else {
	die('<h3>登录信息不完整</h3><a href="/index.php">返回重新登录</a>');
};


@$id = $_REQUEST['id'];

require 'lib/db.php';

@$entry = dbSelect('select *from entry where id=:id',array('id'=>$id));

$type = dbSelect('select name from type where id=:id', array('id'=>$entry['typeId']))

?>

<!DOCTYPE html>
<html>
   <head>
      <title>SuperMarket</title>
	  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8" >
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="bootstrap/css/fileinput.css" rel="stylesheet">
      <script src="bootstrap/js/jquery-1.11.1.min.js"></script>
      <script src="bootstrap/js/bootstrap.min.js"></script>
      <script src="bootstrap/js/fileinput.js"></script>
      <!--[if lt IE 9]>
         <script src="js/html5shiv.js"></script>
         <script src="js/respond.min.js"></script>
      <![endif]-->
   </head>
   <script src="lib/dialog.js"></script>
<script>
	$.ajaxSetup({
		dataType:'JSON',
		error:function(){
					alert('连接错误');
				}
		});

	$(function(){
			$('#submitButton').click(function(){
				$.post('alter.php',$('#submitFrom').serialize(),function(o){
					if(!o.status){
							messageDialog('提示','修改失败！');
						}else{
						messageDialog('提示','修改成功！');
						}
					});
				});
			});
</script>
   <style>
   #Button{background:#d7d7d7;}
   #a{color:#62b0ff;}
   #h4{color:white;font-size:20px}
   #DIV{width:200px;height:220px}
   #price{color:red}
   .but{width:70px;text-align:cneter}
   #but{width:90px;text-align:center}
  </style>
   <body>
<div class="navbar navbar-default">
  <div class="container">
  	<a class="navbar-brand glyphicon glyphicon-shopping-cart" href="First.php" id="a">宜家超市</a>
  		<ul class="nav navbar-nav">
  			<li class="dropdown">
  				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >档案管理 <span class="caret"></span></a>
  					<ul class="dropdown-menu">
  					<li><a href="manager.php">职工列表</a></li>
  					<li><a href="member.php">管理员</a></li>
  					</ul>
  			</li>
  		  </ul>
		<ul class="nav navbar-nav">
			<li class="dropdown">
			 <a href="#" class="dropdown-toggle" data-toggle="dropdown" >商品管理 <span class="caret"></span></a>
				<ul class="dropdown-menu">
					<li><a href="Addmerchandise.php">商品进货</a></li>
					<li><a href="merchandiseDish.php">商品列表</a></li>
				</ul>
			</li>
		  </ul>
		<ul class="nav navbar-nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >营业管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="#">支出明细</a></li>
						<li><a href="#">收入明细</a></li>
					</ul>
				</li>
			</ul>
			<ul class="nav navbar-nav">
			<li class="dropdown">
			 <a href="#" class="dropdown-toggle" data-toggle="dropdown" >我的购物车 <span class="caret"></span></a>
				<ul class="dropdown-menu">
					<li><a href="Adddesk.php">我的商品</a></li>
					<li><a href="#">消费记录</a></li>
					<li><a href="#">我的收藏</a></li>
				</ul>
			</li>
		  </ul>
			<ul class="nav navbar-nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >权限管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="#">我的权限</a></li>
						<li><a href="#">关于超市</a></li>
					</ul>
				</li>
			</ul>
	 	 <ul class="nav navbar-nav">
	  		<li class="dropdown">
	  			<a href="#" class="dropdown-toggle" data-toggle="dropdown" >登录管理 <span class="caret"></span></a>
	  				<ul class="dropdown-menu">
				  		<li><a href="#"  data-toggle="modal" data-target="#2">退出登录</a></li>
	  				</ul>
		</li>
	</ul>
 </div>
</div>
	<div id="2" class="modal">
					<div class="modal-dialog">				
					<div class="modal-content">
							<div class="modal-header">
								<span class="close" data-dismiss="modal">&times;</span>
								  <div class="modal-title">
									<h4>确定退出登录</h4>
								  </div>
									</div>
							<div class="modal-body">
								你确定要退出登录吗？
							</div>
							<div class="modal-footer">
							 <a type="submit" class="btn btn-default" href="logout.php">确定</a>
							 <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							</div>
						</div>
					</div>
				</div>
	<div class="container">
		<div class="row">
			<div class="col-sm-8 col-md-6 col-lg-5">
		        <div class="panel panel-primary">
			            <div class="panel-heading">
			               <h4 id="h4">【<?php echo $entry['name']; ?>】</h4>
			            </div>
		                    <div class="panel-body">
		                    <form id="submitFrom" class="form-horizontal" enctype="multipart/form-data">
		                    <div class="form-group">
		                        <label class="control-label col-sm-3 hidden-xs">商品：</label>
		                        <div class="col-sm-9">
		                            <input required="required" name="name" value="<?php echo $entry['name'];?>" class="form-control" id="input" disabled="disabled"/>
		                        </div>
		                    </div>
		                    
		                    <div class="form-group">
		                        <label class="control-label col-sm-3 hidden-xs">单价：</label>
		                        <div class="col-sm-9">
		                            <input required="required" name="price" id="price" value="<?php echo $entry['price']; ?>" type="number" min="1" class="form-control" placeholder="单价">
		                        </div>
		                    </div>
		                    <div class="form-group">
		                        <label class="control-label col-sm-3 hidden-xs">类型：</label>
		                        <div class="col-sm-9">
		        				  <select  class="form-control" name="typeId" disabled="disabled">
			        				  <option><?php echo $type['name']; ?></option>
		        		 		 </select>
		                   </div> 
		                 </div>
		                    <div class="form-group">
		                        <label class="control-label col-sm-3 hidden-xs">图片：</label>
		                        <div class="col-sm-8">
		                            <div class="thumbnail" id="DIV">
		                            <img src="img/<?php echo $entry['imgUrl']; ?>"/>
		                            </div>
			                        <input  name="img" class="fileinput" type="file" id="fileinput" disabled="disabled"/>
		                        </div>
		                    </div>
		                </form>
		                    <div class="row">
		                        <div class="col-xs-4">
		                            <button  id="submitButton" class="btn btn-primary btn-block but">修改</button>
		                        </div>
		                        <div class="col-xs-4">
		                          	<a href="merchandiseDish.php" class="btn btn-primary but">取消</a>
		                        </div>
		                        <div class="col-xs-4">
		                          	<a href="merchandiseDish.php" class="btn btn-warning" id="but">查看列表</a>
		                        </div>
		                    </div>
		            </div>
		        </div>
			</div>
		</div>
	</div>
		<script>
   		$('.fileinput').fileinput({
   			uploadUrl:'up.php',
   			textEncoding:'UTF-8',
   			removeLabel:'删除',
   			removeTitle:'删除你所选中的文件',
   			cancelLabel:'取消',
   			browseLabel:'浏览',
   			uploadLabel:'上传',
   			showUpload:true,
   			showCancel:true,
   			showRemove:true,
   			showPreview:false,
   			showCaption:true,
   			uploadExtraData:true,
   			
   		});
   	</script>
</body>

</html>









